/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ScanPartitioner.java
 *
 * Created on Mar 18, 2010, 5:18:38 PM
 */

package hadoopscan;

import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Partitioner;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;

/**
 *
 * @author Takeshi
 */
public class ScanPartitioner
        extends Partitioner<Text,LongWritable>
        implements Configurable {

    private Configuration conf;

    @Override
    public void setConf(Configuration conf) {
        this.conf = conf;
        initPartitioner();
    }

    @Override
    public Configuration getConf() {
        return conf;
    }

    private void initPartitioner() {
        // TODO any initialization goes here
    }

    @Override
    public int getPartition(Text key, LongWritable value, int numReduceTasks) {
        // TODO return a partition in [0, numReduceTasks)
        return key.hashCode() % numReduceTasks;
    }
}
